<template>
	<view id="guide">
		<video id="video" src="/static/guide.mp4" :direction="0" :autoplay="false" :controls="false" :show-play-btn="false"
		 :show-center-play-btn="false" :enable-progress-gesture="false" objectFit="fill" @timeupdate="timeupdate" @ended="goIndex"></video>
		<cover-view @click="goIndex">立即体验</cover-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		onShow() {
			let videoContext = uni.createVideoContext('video', this)
			videoContext.play()
		},
		methods: {
			timeupdate(event) {
				uni.getSystemInfo({
					success: (data) => {
						if (data.platform == 'ios') {
							if (event.detail) {
								event.detail.diff = event.detail.duration - event.detail.currentTime;
								if (event.detail.diff < 0.4) {
									this.goIndex()
								}
							}
						}
					}
				})

			},
			goIndex() {
				uni.switchTab({
					url: '/pages/index/index'
				});
			}
		}
	}
</script>

<style>

</style>
